package com.example.jedis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述该类
 *
 * @author <a href="920786312@qq.com">周飞</a>
 * @class: RedisTestController
 * @date 2022/2/3 14:11
 * @Verson 1.0 -2022/2/3 14:11
 * @see
 */
@RestController
public class RedisTestController {
    @Autowired
    private RedisTemplate redisTemplate;
    
    @RequestMapping("/redisTest")
    public String testRedis() {
        // 设置值到redis
        redisTemplate.opsForValue().set("k1", "v1");
        // 从redis获取值
        String name = (String) redisTemplate.opsForValue().get("k1");
        return name;
    }
}